//get_everywhere_coupon
//领取无门槛减免券
exports.get_everywhere_coupon = function (req, res) {

    var bodyParams = req.routeInfo.bodyParams;
    //最终结果
    var resultData = {};

    //任务流创建
    async.waterfall([

            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.searchUserCashCoupon+"/ucc_uid/"+bodyParams.user_id+"/ucc_ccid/"+bodyParams.coupon_id,
                        method: 'POST',
                        data: {
                            fields:["ucc_id"].join(",")
                        }
                    },
                    function (err, data) {
                        //判断是否有错误信息
                        if (err) {
                            return RES.response(res, false, data);
                        }
                        var is_get = data.data;
                        if(is_get.length>4){
                            return RES.response(res, false, "您已经领取过啦");
                        }else{
                            cb();
                        }
                    }
                );
            },
            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.addUserCashCoupon,
                        method: 'POST',
                        data: {
                            ucc_uid: bodyParams.user_id,
                            ucc_ccid: bodyParams.coupon_id,
                            ucc_from_type: 1
                        }
                    },
                    function (err, data) {
                        //判断是否有错误信息
                        if (err) {
                            return RES.response(res, false, data);
                        }
                        resultData.addData = data.data;
                        cb();
                    }
                );
            },

        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

};